#include <bits/stdc++.h>

using namespace std;

struct node
{
	int direct;
	int x,y;
	int cnt=-1;
};

// bool cmp(node a,node b){
// 	if(a.x!=b.x){
// 		return a.x>b.x;
// 	}else{
// 		return a.y>b.y;
// 	}
// }

node arr[55];
int N;

void go(){
	for (int i = 0; i < N; ++i)
	{
		for (int j = i+1; j < N; ++j)
		{
			if(arr[i].direct==arr[j].direct){
				int direct=arr[i].direct;
				if(direct==0&&arr[i].x==arr[j].x){
					node *p=&(arr[i].y<arr[j].y?arr[i]:arr[j]);
					p->cnt=abs(arr[i].y-arr[j].y);
				}else if(direct==1&&arr[i].y==arr[j].y){
					node *p=&(arr[i].x<arr[j].x?arr[i]:arr[j]);
					p->cnt=abs(arr[i].x-arr[j].x);
				}
			}else{
				node *a=&(arr[i].direct==0?arr[i]:arr[j]);
				node *b=&(arr[i].direct==1?arr[i]:arr[j]);
				if(a->x >= b->x&&a->y <= b->y){
					int x=a->x - b->x;
					int y=b->y - a->y;
					if(x<y){
						a->cnt=y;
					}else if(y<x){
						b->cnt=x;
					}
				}
			}
		}
	}
}

int main(int argc, char const *argv[])
{
	scanf("%d%*c",&N);
	for (int i = 0; i < N; ++i)
	{
		char direct;scanf("%c%*c",&direct);
		int x,y;scanf("%d%d%*c",&x,&y);
		arr[i].direct=(direct=='N'?0:1);
		arr[i].x=x;
		arr[i].y=y;
	}
	go();
	for (int i = 0; i < N; ++i)
	{
		if(arr[i].cnt==-1){
			printf("Infinity\n");
		}else{
			printf("%d\n", arr[i].cnt);
		}
	}
	return 0;
}